package com.community.web.controller.plot;

import com.community.body.domain.ZyOwnerRoom;
import com.community.body.dto.CheckDTO;
import com.community.body.service.IZyOwnerRoomService;
import com.community.body.vo.BindingVO;
import com.community.common.annotation.Log;
import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.core.page.TableDataInfo;
import com.community.common.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 房屋绑定 Controller
 * 
 * @author community
 * @date 2024-04-11
 */
@RestController
@RequestMapping("/plot/check")
public class ZyOwnerRoomController extends BaseController
{
    @Resource
    private IZyOwnerRoomService zyOwnerRoomService;

    /**
     * 查询房屋绑定 列表
     */
    @PreAuthorize("@ss.hasPermi('plot:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckDTO checkDTO)
    {
        startPage();
        List<CheckDTO> list = zyOwnerRoomService.selectZyOwnerRoomList(checkDTO);
        return getDataTable(list);
    }

    /**
     * 导出房屋绑定 列表
     */
//    @PreAuthorize("@ss.hasPermi('plot:check:export')")
//    @Log(title = "房屋绑定 ", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ZyOwnerRoom zyOwnerRoom)
//    {
//        List<ZyOwnerRoom> list = zyOwnerRoomService.selectZyOwnerRoomList(zyOwnerRoom);
//        ExcelUtil<ZyOwnerRoom> util = new ExcelUtil<ZyOwnerRoom>(ZyOwnerRoom.class);
//        util.exportExcel(response, list, "房屋绑定 数据");
//    }

    /**
     * 获取房屋绑定 详细信息
     */
    @PreAuthorize("@ss.hasPermi('plot:check:query')")
    @GetMapping(value = "/{ownerRoomId}")
    public AjaxResult getInfo(@PathVariable("ownerRoomId") Long ownerRoomId)
    {
        return success(zyOwnerRoomService.selectZyOwnerRoomByOwnerRoomId(ownerRoomId));
    }

    /**
     * 新增房屋绑定 
     */
    @PreAuthorize("@ss.hasPermi('plot:check:add')")
    @Log(title = "房屋绑定 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZyOwnerRoom zyOwnerRoom)
    {
        return toAjax(zyOwnerRoomService.insertZyOwnerRoom(zyOwnerRoom));
    }

    /**
     * 修改房屋绑定 
     */
    @PreAuthorize("@ss.hasPermi('plot:check:edit')")
    @Log(title = "房屋绑定 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZyOwnerRoom zyOwnerRoom)
    {
        return toAjax(zyOwnerRoomService.updateZyOwnerRoom(zyOwnerRoom));
    }

    /**
     * 删除房屋绑定 
     */
    @PreAuthorize("@ss.hasPermi('plot:check:remove')")
    @Log(title = "房屋绑定 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ownerRoomIds}")
    public AjaxResult remove(@PathVariable Long[] ownerRoomIds)
    {
        return toAjax(zyOwnerRoomService.deleteZyOwnerRoomByOwnerRoomIds(ownerRoomIds));
    }

    @GetMapping("/bindingList")
    public TableDataInfo getStatusList(ZyOwnerRoom zyOwnerRoom) {
        List<BindingVO> list = zyOwnerRoomService.getStatusList(zyOwnerRoom);
        return getDataTable(list);
    }
}
